package com.greenline.push.services;

import javax.annotation.Resource;

import org.apache.log4j.Logger;

import com.greenline.push.service.core.throttle.ThrottleMangerCache;
import com.greenline.push.service.core.tmpl.AppChannelCache;
import com.greenline.push.service.core.tmpl.AppTemplateCache;
import com.greenline.push.service.core.tmpl.GroupAppCache;
import com.greenline.push.service.core.tmpl.TemplateCache;
import com.greenline.push.service.core.utils.Constants;

/**
 * 
 * @Type RefreshConfigServiceImpl
 * @Desc 刷新配置项
 * @author shuai.zuo
 * @date 2014年10月13日
 * @Version V1.0
 */
public class RefreshConfigServiceImpl implements RefreshConfigService {
    @Resource
    private AppChannelCache appChannelCache;
    @Resource
    private TemplateCache tempalteCache;
    @Resource
    private ThrottleMangerCache throttleManger;
    @Resource
    private AppTemplateCache appTemplateCache;
    @Resource
    private GroupAppCache groupoAppCache;

    private Logger logger = Constants.LOG_DUBBO;

    @Override
    public boolean refreshTemplateCache() {
        logger.info("{refresh}收到刷新template请求");
        tempalteCache.reload();
        return true;
    }

    @Override
    public boolean refreshAppChannelCache() {
        logger.info("{refresh}收到刷新appChannel请求");
        appChannelCache.reload();
        return true;
    }

    @Override
    public boolean refreshChannelThrottle() {
        logger.info("{refresh}收到刷新channelThrottle请求");
        return throttleManger.reloadAllThrottleConfig();
    }

    @Override
    public boolean refreshDomainAppTemplateCache() {
        logger.info("{refresh}收到刷新appTemplate请求");
        return appTemplateCache.reload();
    }

    @Override
    public boolean refreshGroupAppCache() {
        logger.info("{refresh}收到刷新groupapp请求");
        return groupoAppCache.reload();
    }

}
